import { createSlice } from "@reduxjs/toolkit"

const userData = createSlice({
    name: 'users',
    initialState: {
        userInf: [
          { account: 'esun', password: '123456' }], // 改为数组
          isLoggedIn: false // 新增状态字段
      },
      reducers: {
        checkLogin(state, action) {
          const result = state.userInf.find(item => 
            item.account === action.payload.account && 
            item.password === action.payload.password // 注意字段名对应
          );
          return {
            ...state,
            isLoggedIn: !!result // 添加登录状态标识
          };
        }
      }
}

)
const { checkLogin } = userData.actions
export {checkLogin}
const reducer = userData.reducer
export default reducer